/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Buku;

import Entity.Buku;
import Entity.DatabaseConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author admin
 */
public class ControllerUpdate {

    private Connection conn = DatabaseConnection.getConnection();

    public static Buku search(String id_buku) throws SQLException {
        return Buku.Search(id_buku);

    }

    public void updateBuku(Buku buku) throws SQLException {
        PreparedStatement pt = null;
        String id = buku.getIdBuku();
        int jml = buku.getJumlah();
        int stok = buku.getStok();

        String sql = "update buku set jumlah = ?, stok = ? where idbuku = ? ";
        pt = conn.prepareStatement(sql);
        pt.setInt(1, jml);
        pt.setInt(2, stok);
        pt.setString(3, id);

        pt.executeUpdate();
    }
}
